/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.Productos;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

/**
 *
 * @author dianacha
 */
public class FormularioBlusa extends JDialog implements ActionListener{
    
    private JLabel lBlusa;
    private JTextField largoMangas;
    private JTextField anchoPecho;
    private JTextField cintura;
    private JButton bAceptar;
    private JButton bCancelar;
    private ArrayList<String> datosBlusa;
    
    public FormularioBlusa(JDialog framePadre, boolean modal){
        super(framePadre, modal);
        setTitle("Cajero Cocos - Productos - Blusa");
        //Image icono = Toolkit.getDefaultToolkit().getImage("images/logo25x25.jpg");
        //setIconImage(icono);
        inicializarComponentes();
        organizarComponentes();
        pack();
        setResizable(false);
        setVisible(true);
    }
    
    private void inicializarComponentes() {
        lBlusa = new JLabel("Datos Blusas", new ImageIcon("/GUI/images/shopping-bag-96x96.png"), SwingConstants.LEFT);
	lBlusa.setFont(new Font("Arial", Font.BOLD, 18));
	lBlusa.setForeground(new Color(78,79,99,190));
        
        largoMangas = new JTextField();
        anchoPecho = new JTextField();
        cintura = new JTextField();
        
        datosBlusa=new ArrayList<>();
        
	bAceptar = new JButton("Aceptar");
	configurarBoton(bAceptar);
	bCancelar = new JButton("bCancelar");
	configurarBoton(bCancelar);
    }
    
    private void configurarBoton(JButton boton) {
        boton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        boton.setOpaque(false);
	boton.setBackground(new Color(0,0,0,0));
	boton.addActionListener(this);
    }
    
    private void organizarComponentes() {
        /* ****************** Parte Norte */
        
        JPanel pEncab = new JPanel();//ec ef
	pEncab.setBorder(BorderFactory.createEmptyBorder(20,40,0,40));//n,w,s,e
	pEncab.setBackground(new Color(0,0,0,0));
	pEncab.add(lBlusa, BorderLayout.NORTH);
        
        /* ****************** Parte Central */
        
        JPanel pFormulario = new JPanel(new GridLayout(3,2,0,2));
	pFormulario.setBorder(BorderFactory.createEmptyBorder(0,40,0,40));//n,w,s,e
	pFormulario.setBackground(new Color(0,0,0,0));
        
        pFormulario.add( new JLabel( "Largo Mangas:" ));
        pFormulario.add( largoMangas );
	pFormulario.add( new JLabel( "Ancho Pecho:" ) );
        pFormulario.add( anchoPecho );
	pFormulario.add( new JLabel( "Cintura:" ) );
        pFormulario.add( cintura );
        
        /* ****************** Parte Sur */
        
        JPanel pBotones = new JPanel(new GridLayout(1,3));
        pBotones.setBorder(BorderFactory.createEmptyBorder(0,0,20,0));//n,w,s,e
	pBotones.setBackground(new Color(0,0,0,0));
	pBotones.add(bAceptar);
	pBotones.add(bCancelar);
	
	/* ****************** General */
	setLayout(new BorderLayout(0,20)); // eC, eF
	this.add(pEncab, BorderLayout.NORTH);
	this.add(pFormulario, BorderLayout.CENTER);
	this.add(pBotones, BorderLayout.SOUTH);
    }
    
    private void limpiarCampos(){
        largoMangas.setText("");
        anchoPecho.setText("");
        cintura.setText("");
    }
    
    @Override
    public void actionPerformed(ActionEvent ae) {
        if(ae.getSource()==bAceptar){
            aceptarDatosBlusa();
        }
        if(ae.getSource()==bCancelar){
            cancelarDatosBlusa();
        }
    }

    private void aceptarDatosBlusa() {
        datosBlusa.clear();
        
        datosBlusa.add(0, largoMangas.getText());
        datosBlusa.add(1, anchoPecho.getText());
        datosBlusa.add(2, cintura.getText());
    }

    private void cancelarDatosBlusa() {
        limpiarCampos();
        dispose();
    }
    
    public ArrayList<String> getDatos(){
        return datosBlusa;
    }
}
